package com.cunjin.visitor.comtroller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cunjin.base.controller.BaseController;
import com.cunjin.visitor.entity.VisitorEntity;
import com.cunjin.visitor.service.VisitorService;

@Controller
@RequestMapping("/visitor")
public class VisitorComtroller extends BaseController<VisitorEntity> {

	@Autowired
	private VisitorService service;
	
		//http://localhost:8090/cunjin-dorm/visitor/myqueryAll
		@RequestMapping("/myqueryAll")
		@ResponseBody
		public Map<String, Object> myqueryAll(VisitorEntity entity) {
			
			Map<String, Object> all = service.queryAll();
			return all;
		}
		
		/**
		 * 分页
		 * @param page
		 * @param rows
		 * @param searchName
		 * @return
		 */
		@RequestMapping("/findWithPage")
		@ResponseBody
		public Map<String, Object>  findWithPage(int page,int rows,String searchName) {
		
			Map<String, Object>  fy = service.queryByPage(page,rows,searchName);
			return fy;
		}
		
		/**
		 * 添加
		 * @param page
		 * @param rows
		 * @return
		 */
		@RequestMapping("/addVisitor")
		@ResponseBody
		public Map<String, Object> addVisitor(VisitorEntity entity) {
			
			Map<String, Object>  map = service.insert(entity);
			return map;
		}
		
		
		/**
		 * 
		 * 删除
		 * @param dles
		 * @return
		 */
		@RequestMapping("/delVisitor")
		@ResponseBody
		public Map<String, Object>  delVisitor(String dles) {
			
			String[] split = dles.split(",");
			Map<String, Object>  mydelete = service.deleteByids(split);
			return mydelete;
		}

		/**
		 * 更新
		 * @param entity
		 * @return
		 */
		@RequestMapping("/updateVisitor")
		@ResponseBody
		public Map<String, Object>  updateVisitor(VisitorEntity entity) {
			
			Map<String, Object>  myupdate = service.update(entity);
			return myupdate;
		}

}
